package com.ioudi.digu.util;


import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.servlet.FrameworkServlet;

import flex.messaging.FlexContext;

public class ContextUtil
{
	private static String serverRootPath;
	
	public static Object getBeanInFlexContext(String name)
	{
		WebApplicationContext wc = WebApplicationContextUtils
				.getWebApplicationContext(FlexContext.getServletContext(), 
						FrameworkServlet.SERVLET_CONTEXT_PREFIX + "springflex");
		if (wc != null)
		{
			return wc.getBean(name);
		}
		return null;
	}
	
	/**
	 * not contain "/"
	 * @return
	 */
	public static String getServerRootPath()
	{
		return serverRootPath;
	}
	
	public static void setServerRootPath(String value)
	{
		serverRootPath = value;
	}
}
